package com.sunkey.rest.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {

    @RequestMapping(value = "/testGet", method = RequestMethod.GET)
    @ResponseBody
    public Response testGet(@RequestParam("name") String name, @RequestParam(required = false) String sex) {
        System.out.println(name);
        Response response = new Response();
        response.setName("hello:" + name);
        response.setSex(1);
        return response;
    }

    @RequestMapping(value = "/testUser", method = RequestMethod.GET)
    @ResponseBody
    public Response testUser() {
        Response response = new Response();
        response.setName("hello: sunkey");
        response.setSex(1);
        return response;
    }

    @RequestMapping(value = "/testPost", method = RequestMethod.POST)
    @ResponseBody
    public Response testPost(@RequestParam(required = false) String name, @RequestBody String xml) {

        System.out.println(name);
        System.out.println(xml);

        Response response = new Response();
        response.setName("hello:" + name);
        response.setSex(1);
        return response;
    }

}
